/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Tables;

import java.sql.*;

/**
 *
 * @author rehgon
 */
public class Lieferanten {
    
    public static void insertLieferant(Connection conn, String name, String adresse, int bankverbindung) {
        try {
            Statement stmt = conn.createStatement();
            stmt.executeUpdate("insert into Lieferanten (name, adresse, bankverbindung)"
                    + "values('" + name + "','" + adresse + "'," + bankverbindung + ")"
            );
            System.out.println("Der Lieferant mit den Angaben: " + name + " | " + adresse + " | " + bankverbindung + " wurde erstellt");
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }
    
    public static void selectAllLieferanten(Connection conn) {
        try {
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("select * from Lieferanten");
            while(rs.next()) {
                System.out.println(rs.getInt("lieferantId") + " | " + rs.getString("name") + " | " + rs.getString("adresse") + " | " + rs.getInt("bankverbindung"));
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }
    
}
